<script type="text/javascript">
var enable_submit = true;
function submit_cgsnapshot_clone() {
    var cgsnapshot_name = $("#volume_cgsnapshot_clone").find("#clone_volume_name");
    var bValid = true;
    bValid = bValid && checkRegexp(cgsnapshot_name, /^[0-9a-z-]+$/, "名称应由小写英文字母、数字、中划线(英文)构成.");
    bValid = bValid && checkLength(cgsnapshot_name, "名称", 1, 32);
    if (bValid) {
        if (enable_submit) {
            enable_submit = false;
            $submitBtn = $('.modal-footer').find('.btn-blue');
            $submitBtn.html('<i class="fa fa-spinner fa-spin" style="margin:3px 6px;"></i>');
            $('.rtn-tip').slideUp('fast');
            $.post("/cgsnapshot_clone", {
                    "name": cgsnapshot_name.val(),
                    "id": "{{ cgsnapshot.id }}"
                },
                function(data) {
                    if (data.reply.is_success) {
                        angular.element('#cgsnapshot_create').scope().close();
                        $('#cgsnapshot_table').trigger("reloadGrid");
                        /*cgsnapshots_show("{{ cgsnapshot.volume_id }}")
                        SelfAlert("克隆存储卷完成", "完成提示");*/
                    } else {
                        error = data.reply.error;
                        $('.rtn-tip').text(error).slideDown('fast');
                        $submitBtn.html(SelfTranslate("[[ 'label ok'|translate ]]"));
                        enable_submit = true;
                    }
                });
        }
    }
}
$(function() {
    /* 为小图标绑定鼠标移入移出事件 */
    var obj = {
        "clone_volume_name": "由1到32位小写英文字母、数字、中划线(英文)构成。"
    }
    bindMouseEvent('#volume_cgsnapshot_clone', obj);
    /* 为小图标绑定鼠标移入移出事件结束 */
});
</script>
<div class="modal-header">
    <h3>克隆存储卷</h3>
</div>
<div class="modal-body modal-body-height" id="volume_cgsnapshot_clone">
    <div class="cgsnapshot-clone-box">
        <div class="rtn-tip"></div>
        <table class="base-info">
            <tr>
                <td>
                    <label>名称</label><a>*</a>
                </td>
                <td colspan="3">
                    <input id="clone_volume_name" name="clone_volume_name" size="25" type="text" />
                    <i class="fa fa-question-circle" itype="clone_volume_name"></i>
                </td>
            </tr>
        </table>
    </div>
    <div class="error-tip">
        <p></p><span></span>
    </div>
    <div class="tip">
        <p></p><span></span>
    </div>
</div>
<div class="modal-footer">
    <button class="btn btn-blue" ng-click="clone_ok()">[[ 'label ok'|translate ]]</button>
    <button class="btn btn-white" ng-click="cancel()">[[ 'label cancel'|translate ]]</button>
</div>
